# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=tuxcards
pkgver=2.2.1
pkgrel=8
pkgdesc="A hierarchical notebook to enter and manage notes and ideas in a structured manner"
arch=('loong64' 'x86_64')
url="https://www.tuxcards.de"
license=('GPL')
depends=('qt5-base')
makedepends=('dos2unix')
source=(https://www.tuxcards.de/src/tuxcards-${pkgver}/${pkgname}-${pkgver}.tar.gz tuxcards.desktop tuxcards-qt5.patch)
sha512sums=('70d420f57e4d08341f4137fce0fd4d7afe59b9af5a4ef821d93b3aac912401772cdab2d240470ab96ba6c91a1548eecac87fcaa6c746e93d18d7b5be69d86052'
            '947d683b1f66a29815277f3cafeabc2fe8a639faad78a5eac3de96ea7b65c38865700371282697dcf2e9d4bc50c3c441d4fa38c0ea6b84a48c5af2bcc145a37a'
            '86a79238d0e37a9d085c13ef4972d4ee7449f0e9b3ab40910f3fbca9ec6c40c3b3f2c666112517a6dbd04d3c7b60fcbc160635b950f12c9a323a84857d60ff57')

prepare() {
  cd $pkgname
  find -type f | xargs dos2unix # Fix line endings
  patch -lp1 -i ../tuxcards-qt5.patch # Port to Qt5
  sed -i 's|/usr/local/doc/tuxcards/flowers/|/usr/share/tuxcards/flowers/|' src/CTuxCardsConfiguration.cpp
}

build() {
  cd "${srcdir}/${pkgname}"
  qmake-qt5 tuxcards.pro
  make
}

package() {
  cd "${srcdir}/${pkgname}"
  install -D -m755 tuxcards "${pkgdir}/usr/bin/tuxcards"
  install -D -m644 src/icons/lo16-app-tuxcards.png "${pkgdir}/usr/share/icons/locolor/16x16/apps/tuxcards.png"
  install -D -m644 src/icons/lo32-app-tuxcards.png "${pkgdir}/usr/share/icons/locolor/32x32/apps/tuxcards.png"
  install -D -m644 "${srcdir}/tuxcards.desktop" "${pkgdir}/usr/share/applications/tuxcards.desktop"
  install -D -m644 src/translations/tuxcards_de.qm "${pkgdir}/usr/share/tuxcards/i18/tuxcards_de.qm"
  install -d "${pkgdir}/usr/share/tuxcards/flowers/"
  install -m644 src/gui/cactusbar/flowers/*.gif "${pkgdir}/usr/share/tuxcards/flowers/"
}
